/**
 * 
 */
package info.niwota.group;

import java.util.List;

import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;

/**
 * @author qiangli
 *
 */
public class License {

	/**
	 * 
	 */
	private License() {
	}
	
	public static boolean isLicensed(Context ctx) {
		return isEtalkAvailable(ctx);
	}

	private static boolean isEtalkAvailable(Context ctx) {
		final PackageManager pm = ctx.getPackageManager();
		final Intent i = createEtalkIntent();
		List<ResolveInfo> l = pm.queryIntentActivities(i,
				PackageManager.MATCH_DEFAULT_ONLY);
		return (l.size() > 0);
	}
	
	public static Intent createEtalkIntent() {
		final Intent i = new Intent(Intent.ACTION_GET_CONTENT);
		i.setClassName("instant.mail", "instant.mail.EtalkContactsActivity");
		return i;
	}
}
